package org.company.earth.arithmetic;

import java.util.List;

public class ShellSort<T> extends InsertSort<T> {
    
    
    @Override
    public void sort(List<T> list) {
        int length = list.size();
        int step = length / 2;
        while(step >= 1) {
            this.shellSort(list, step);
            step = step/2;
        }
    }
    
    /**
     * 不稳定的算法
     * @param list
     * @param step
     */
    protected void shellSort(List<T> list,int step) {
        int length = list.size();
        for(int i = step; i < length ; i++) {
            this.insertSort(list, i ,step);
        }
    }
}
